//
//  RWSystemMessageViewController.m
//  RedWine
//
//  Created by Liufangfang on 2017/5/9.
//  Copyright © 2017年 HuiBangKe. All rights reserved.
//

#import "RWDetailMessageViewController.h"

#import "RWMessageModel.h"

@interface RWDetailMessageViewController ()

@property (nonatomic, copy) RWSystemMessageModel *systemMessageModel;

@end

@implementation RWDetailMessageViewController

#pragma mark - View LifeCycle Methods

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setSystemMessageUI];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Load Data

-(void)setDetailMessage:(NSArray *)detailMessage{

    _detailMessage = detailMessage;
}

#pragma mark - Set Methods

- (void)setNavigation{

    self.title = _titile;
}

- (void)setSystemMessageUI{

    _systemMessageTV = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, FTY_SCREEN_WIDTH, FTY_SCREEN_HEIGHT-FTY_NAVIGATION_HEIGHT) style:UITableViewStylePlain];
    [self.view addSubview:_systemMessageTV];
    _systemMessageTV.dataSource = self;
    _systemMessageTV.delegate = self;
    _systemMessageTV.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
}

#pragma mark - <UITableViewDataSource>

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return _detailMessage.count;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 80.*FTY_HEIGHT_BASE;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    static NSString *const systemMessageID = @"systemMessageID";
    UITableViewCell *systemMessageCell = [tableView dequeueReusableCellWithIdentifier:systemMessageID];
    if (!systemMessageCell) {
        
        systemMessageCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:systemMessageID];
    }
    
    NSInteger row = indexPath.row;
    
    systemMessageCell.textLabel.text = [_detailMessage[row] objectForKey:@"message_body"];
    systemMessageCell.textLabel.numberOfLines = 0;
    systemMessageCell.textLabel.font = FTY_FONTTSIZE(13);
    
    return systemMessageCell;
}

#pragma mark - <UITableViewDelegate>

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
